package stz.flash.option.app;

import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import stz.flash.Info;
import stz.flash.option.OptionLabel;
import stz.flash.string.OptionInformation;
import stz.flash.string.OptionString;
import blackberry.util.field.DjChoiceField;
import blackberry.util.field.DjLabelField;



public class HomeScreenHotkeyChoiceField extends DjChoiceField implements FieldChangeListener{
	
	private HomeScreenHotkeyOption homeScreenHotkeyOption = HomeScreenHotkeyOption.getIns();
	
	public HomeScreenHotkeyChoiceField() {
		super(DjLabelField.createSimpleLabel(OptionString.HOMESCREEN_HOTKEY_CHOICE_FIELD), 
				OptionLabel.createInfoLabel(OptionInformation.HOMESCREEN_HOTKEY_CHOICE_FIELD),
				Info.getHomeScreenHotkeyList());
		
		setSelectedIndex(homeScreenHotkeyOption.getHomeScreenHotkey());
		setChangeListener(this);
	}
	
//	private static String[] getAlphabetList(){
//		String[] alphabet = new String[27];
//		alphabet[0] = OtherInfo.KEY_NONE;
//		for (int i = 1; i < alphabet.length; i++){
//			alphabet[i] = String.valueOf((char) (i+64));
//		}
//		return alphabet;
//	}

	public void fieldChanged(Field field, int context) {
		if (context == PROGRAMMATIC || context == 0)
			return;
		
		setHomeScreenHotkey((String) getChoice(getSelectedIndex()));
	}
	
	public String getHomeScreenHotkey() {
		return homeScreenHotkeyOption.getHomeScreenHotkey();
	}

	public void setHomeScreenHotkey(String key) {
		homeScreenHotkeyOption.setHomeScreenHotkey(key);
	}
}

